

<#include "/base/common/head.html"/>

 <div class="easyui-panel addPage multiple" data-options="fit:true,border:false,novalidate:true">
    <form class="easyui-form" id="form1" method="post" data-options="novalidate:true">
        <table class="table1">
        	
					<tr>
		           		<th><span>姓名</span></th>
		               	<td>
		               		<div class="wrap_input"><input class="easyui-textbox" addClear name="name" id="name" value="" tabindex="1"
		               			data-options="required:true, fit:true"></input></div>
		           		</td>
		           		<th><span>日期</span></th>
		               	<td>
		               		<div class="wrap_input"><input class="easyui-datebox" addClear name="theDate1" id="theDate1" value="" tabindex="8"
		               			data-options=" fit: true,editable:false "></input></div>
		           		</td>
						<TD  style="width:100px"></TD>
					</tr>
					
					
					<tr>
		           		<th><span>性别</span></th>
		               	<td>
		               		<div class="wrap_input" id="sex_div">
		               			<!-- 
						     	<input class="easyui-radiobutton" name="sex" value="男" id="sex_男">男
						   		<input class="easyui-radiobutton" name="sex" value="女" id="sex_女">女
						   		 -->
		               		</div>
		           		</td>
						<th><span>时间</span></th>
		               	<td>
		               		<div class="wrap_input"><input class="easyui-datetimebox" addClear name="theTime1" id="theTime1" value="" tabindex="9" 
		               			data-options=" fit: true,showSeconds:false,editable:false"></input></div>
		           		</td>
						<TD  style="width:100px"></TD>
					</tr>
					
					<tr>
						<th><span>爱好</span></th>
		               	<td>
		               		<div class="wrap_input" id="hobby_div">
		               			<!-- 
		               			<input class="easyui-checkbox" name="hobby" value="读书" id="hobby_读书">读书
		               			<input class="easyui-checkbox" name="hobby" value="户外" id="hobby_户外">户外
		               			 -->
		               		</div>	
		           		</td>
						<th><span>年月微调</span></th>
		               	<td>
		               		<div class="wrap_input"><input class="easyui-datetimespinner" name="theDate3" id="theDate3" value="0" tabindex="10"
		               			data-options=" formatter:formatter_ym,parser:parser_ym,fit: true,showSeconds:false"></input></div>
		           		</td>
				
						<TD  style="width:100px"></TD>
					</tr>
					
					<tr>
						<th><span>城市</span></th>
		               	<td>
		               		<div class="wrap_input"><input class="easyui-combobox" addClear panelHeight="auto" name="city" id="city" value="" tabindex="2" 
		               			data-options="fit:true,valueField:'name',textField:'name',url:'${basePath}/base/basis/enumDetail/findByKey?key=demo_city'"></input></div>
		           		</td>
						<th><span>日期微调</span></th>
		               	<td>
		               		<div class="wrap_input"><input class="easyui-datetimespinner" name="theDate2" id="theDate2" value="0" tabindex="11"
		               			data-options=" formatter:formatter_ymd,parser:parser_ymd,fit: true,showSeconds:false"></input></div>
		           		</td>
						<TD  style="width:100px"></TD>
					</tr>
					
					<tr>
						<th><span>课程（多选）</span></th>
		               	<td>
		               		<div class="wrap_input"><input class="easyui-combobox" addClear panelHeight="auto" name="course" id="course" value="" tabindex="3" 
		               			data-options="fit:true,multiple:true,editable:false,valueField:'name',textField:'name',url:'${basePath}/base/basis/enumDetail/findByKey?key=demo_course'"></input></div>
		           		</td>
						<th><span>时间微调</span></th>
		               	<td >
		               		<div class="wrap_input"><input class="easyui-datetimespinner" name="theTime2" id="theTime2" value="0 09:00"  tabindex="12" 
		               			data-options=" fit: true,showSeconds:false"></input></div>
		           		</td>
						<TD  style="width:100px"></TD>
					</tr>
					
					<tr>
						<th><span>茶品（固定）</span></th>
		               	<td>
		               		<div class="wrap_input"><input class="easyui-combobox" addClear panelHeight="auto" name="tea" id="tea" value="" tabindex="4" 
		               			data-options="fit:true,editable:false,valueField:'name',textField:'name',data: [{name: '普洱'},{name: '大红袍'},{name: '白牡丹'},{name: '如莲'}]"></input></div>
		           		</td>
		           		<th><span>整数</span></th>
		               	<td>
		               		<div class="wrap_input"><input class="easyui-numberbox" addClear name="intNum1" id="intNum1" value="" tabindex="13"
		               			data-options=" fit:true"></input></div>
		           		</td>
						<TD  style="width:100px"></TD>
					</tr>
					
					
					<tr>
		           		<th><span>类别</span></th>
		               	<td>
		               		<div class="wrap_input">
			               		<input class="easyui-combobox" addClear panelHeight="auto" name="fullSort.id" id="fullSort.id" value="" tabindex="5"
			               			data-options=" fit:true,editable:false,valueField:'id',textField:'name',
			               			url:'${basePath}/base/basis/sort/findAll?key=fullSort'
			               			,onLoadSuccess:function(){
			               					//取默认值
			               					var dataArr = $('#fullSort\\.id').combobox('getData');
			               					for(var i=0;i<dataArr.length;i++)
			               					{
			               						var obj = dataArr[i];
			               						if(obj.code == '02')
			               						{
			               							$('#fullSort\\.id').combobox('setValue',obj.id);
			               							break;
			               						}
			               					}
			               			}
			               		"></input>
		               		</div>
		           		</td>
						<th><span>整数微调</span></th>
		               	<td>
		               		<div class="wrap_input"><input class="easyui-numberspinner" name="intNum2" id="intNum2" value="5" tabindex="14" 
		               			data-options=" fit:true,editable:false,min:1,max:10"></input></div>	
		           		</td>
				
						<TD  style="width:100px"></TD>
					</tr>
					
					<tr>
						<th><span>类别2（列表）</span></th>
		               	<td>
		               		<div class="wrap_input">
		               			<input class="easyui-combogrid" addClear name="fullSort2.id" id="fullSort2.id" value="" tabindex="6"
		               				data-options=" fit:true,editable:false,idField: 'id',textField: 'name',
									url: '${basePath}/base/basis/sort/findAll?key=fullSort',
									panelWidth: 240,
									columns: [[
										{field:'code',title:'编号',width:60,align:'center'}
										,{field:'name',title:'名称',width:60,align:'center'}
										,{field:'remark',title:'备注',width:100,align:'center'}
									]],
									fitColumns: true
								"></input>
		               		</div>
		           		</td>
						<th><span>实数</span></th>
		               	<td>
		               		<div class="wrap_input"><input class="easyui-numberbox" addClear name="doubleNum1" id="doubleNum1" value="" tabindex="15" 
		               			data-options=" fit:true,precision:2"></input></div>
		           		</td>
				
						<TD  style="width:100px"></TD>
					</tr>
					
					<tr>
						<th><span>标签</span></th>
		               	<td >
		               		<div class="wrap_input"><input class="easyui-tagbox" name="tag" id="tag" value="" tabindex="7" 
		               			data-options="fit:true" ></input></div>
		           		</td>
						<th><span>布尔</span></th>
		               	<td>
		               		<div class="wrap_input">
		               			<input class="easyui-switchbutton" name="boolean1" id="boolean1" data-options="onText:'是',offText:'否'" checked /> 
		               		</div>
		           		</td>
						<TD  style="width:100px"></TD>
					</tr>
					
					<tr>
						<th><span>备注</span></th>
		               	<td colspan="3">
		               		<input class="easyui-textbox" addClear name="remark" id="remark" value="" tabindex="16" 
		               			data-options="multiline:true,height:60,width:'90%'" ></input>
		           		</td>
						<TD  style="width:100px"></TD>
					</tr>
					
           
        </table>
    </form>
</div>

<style type="text/css">

/* 文本显示样式 */
.theTxtClass{font-family: Arial, Helvetica, sans-serif; line-height: 22px; color: #2f8ec7;margin-left:10px;font-size:12px;}

/* 红色文本样式 */
.theRedTxt{color: #ff0000;font-size:14px;}

</style>

<script>

//定义保存回调方法
top.window.subPage.save = save;
function save() {
	
	if($("#form1").form('validate')) {
		$.post("add", getParam(), function(data) {
			if("01" == data.code){//成功
				top.window.closeWindow(); //关闭窗口
				top.window.subPage.loadCurrDatagrid(); //回调方法
				showMsg(data.msg); //显示消息
				
			}else if("04" == data.code){//失败
				showErrorMsg(data.msg); //显示错误消息
			}
		});
		
	}
}

//获取表单数据
function getParam() {
	var param = {
				"id": 0
				,"obj.name": getInputValue("name")
				,"obj.sex": getRedioValue("sex") //单选
				,"obj.hobby": getCheckboxValue("hobby") //复选
				,"obj.city": getInputValue("city")
				,"obj.course": getInputValue("course")
				,"obj.tea": getInputValue("tea")
				,"obj.fullSort.id": getInputValue("fullSort.id")
				,"obj.fullSort2.id": getInputValue("fullSort2.id")
				,"obj.intNum1": getInputValue("intNum1")
				,"obj.intNum2": getInputValue("intNum2")
				,"obj.doubleNum1": getInputValue("doubleNum1")
				,"obj.boolean1": $("#boolean1").switchbutton("options").checked+"" //布尔
				,"obj.theDate1": getInputValue("theDate1")
				,"obj.theDate2": getInputValue("theDate2")
				,"obj.theDate3": getInputValue("theDate3") + "-15" //年月微调
				,"obj.theTime1": getInputValue("theTime1")
				,"obj.theTime2": getInputValue("theTime2")
				,"obj.tag": getInputValue("tag")
				,"obj.remark": getInputValue("remark")
		
	}
	//去除空数据
	for(key in param) {
		if(!param[key]) {
			delete param[key];
		}
	}
	return param;
}

$(function(){
	//清除按钮
	autoAddClear(); //为各组件自动填加‘清除’功能（组件需要增加 addClear属性 ）
	//addClear4TextBox("#name",nameChangeDo); //对于需要使用OnChange事件的组件，单独手动填加
	
	//页面增加焦点切换操作
	addChangeFocusOpe(); 

	//第一个元素设置焦点 
	$('#name').next('span').find('input').focus();  
	
	//构建单选、复选录入组件
	
	{//单选-序列：性别
		var fieldName="sex"; //bo属性名
		var parameter = "男,女"; //序列
		var defaultValue ="男"; //默认值
		
		buildRedio_p(fieldName, parameter, defaultValue); //单选
		//buildCheckbox_p(fieldName, parameter, defaultValue); //复选
	}
	
	{//复选-URL：爱好
		var fieldName="hobby"; //bo属性名
		var url = "${basePath}/base/basis/enumDetail/findByKey?key=demo_hobby"; //数据来源URL
		var urlShowField = "name"; //URL取值属性
		var defaultValue ="静思"; //默认值
		
		buildCheckbox_url(fieldName, url, urlShowField, defaultValue); //复选
		//buildRedio_url(fieldName, url, urlShowField, defaultValue); //单选
	}
	
});

//名称改变时执行的一些操作。（演示清除操作回调）
var nameChangeDo = function(){
	//alert("改变了...");
}

//字符串转日期
function stringToDate(value){
    return new Date(Date.parse(value.replace(/-/g, "/")));
}

//自定义校验
$.extend($.fn.validatebox.defaults.rules, { 
	//注意：自定义验证器名称，一定不能包含数字，否则会不起作用
	
	intNumValidator:{//验证整数2（必须大小整数1）
        validator: function(value){
            return parseInt(value) > parseInt($("#intNum1").val());    
        },    
        message: '必须大于 整数1'   
    },   

    theDateValidator:{//验证日期2（必须大小日期1）
	    validator: function(value){
	        return stringToDate(value) > stringToDate($("#theDate1").val());    
	    },    
	    message: '必须大于 日期1'   
	}
    
});  

</script>
<#include "/base/common/foot.html"/>
